<script type="text/javascript">
function requestTaskDelete(taskId, index){

	$.confirm({
		'title'		: 'DELETE TASK',
		'message'	: 'Do you really want to delete this task?',
		'buttons'	: {
			'No'	: {
				'action': function(){
					$("#confirmBox").slideUp();
				}	// Nothing to do in this case. You can as well omit the action property.
			},
			'Yes'	: {
				'action': function(){
					$("#confirmBox").slideUp();

					//show loading panel in jsloading.jsp
					showLoading();

					controller_url = "${pageContext.request.contextPath}/task/delete.html";

					var json = {
						"taskId" : taskId
					};

					$.ajax({
						url : controller_url,
						data : JSON.stringify(json),
						type : 'POST',
						dataType : "text",
						beforeSend : function(xhr) {
							xhr.setRequestHeader("Accept", "application/json");
							xhr.setRequestHeader("Content-Type", "application/json");
						},
						success : function(string) {
							
							$("#flight" + index).slideUp();
							$("#br" + index).slideUp();

							setTimeout(
									function() {
										$("#flight" + index)
												.remove();
										$("#br" + index)
												.remove();

										function stickyFooter() {
											var footer = $("#footer");
											var pos = footer.position();
											var height = $(
													window)
													.height();
											height = height
													- pos.top;
											height = height
													- footer
															.outerHeight();

											if (height > 0) {
												footer
														.css({
															'margin-top' : height
																	+ 'px'
														});
											}
										}
										;
										stickyFooter();
									}, 0);
							
							setTimeout(function () {
// 								location.reload();
								unShowLoading();
								message = "You deleted this task successfully." ;
								generate('success', message);
								var noOfTask = $(".task-detail").size();
								var noOfActivedTask=$(".bg-white").size();
								var msg=noOfActivedTask+"/"+noOfTask +' TASKS';
								$("#numOfTask").empty().append(msg);

							}, 1000);
							
						},
						error : function(string, status, er) {
							$.confirm({
								'title'		: 'DELETE TASK',
								'message'	: 'Error happened!',
								'buttons'	: {
									'OK'	: {
										'action': function(){
											$("#confirmBox").slideUp();
										}	// Nothing to do in this case. You can as well omit the action property.
									}
								}
							});
						}
					});
				}
			}
		}
	});
}
</script>